//
//  BCBaseTabBarController.swift
//  Blockfolio
//
//  Created by Maybe on 09/05/2021.
//

import UIKit

class BCBaseTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        tabBar.shadowImage = UIImage.color(color: UIColor.white)
        tabBar.backgroundImage = UIImage.color(color: UIColor.white)
        
        addChildViewController(BCCoinListController(), title: "首页", imageName: "home_dark_inactive20x20", selectedImageName: "home_light_active20x20")
        addChildViewController(BCNewsController(), title: "行情", imageName: "portfolio_dark_inactive20x20", selectedImageName: "portfolio_light_active20x20")
        addChildViewController(BCMineController(), title: "个人", imageName: "explore_dark_inactive20x20", selectedImageName: "explore_light_active20x20")
        
        
        
        // Do any additional setup after loading the view.
    }
    

    fileprivate  func addChildViewController(_ childController: UIViewController, title: String, imageName:String, selectedImageName:String) {
        
        childController.title = title
        childController.tabBarItem.setTitleTextAttributes([NSAttributedString.Key.font : UIFont.systemFont(ofSize: 12),NSAttributedString.Key.foregroundColor : UIColor.black], for:.normal)
        childController.tabBarItem.setTitleTextAttributes([NSAttributedString.Key.font : UIFont.systemFont(ofSize: 12), NSAttributedString.Key.foregroundColor : UIColor.black], for: .selected)
        childController.tabBarItem.image = UIImage(named: imageName)?.withRenderingMode(.alwaysOriginal)
        childController.tabBarItem.selectedImage = UIImage(named: selectedImageName)?.withRenderingMode(.alwaysOriginal)
        let navigationVC = BCBaseNavigationViewController(rootViewController: childController)
        addChild(navigationVC)
    }
    
    

}
